<template>
  <!-- 企业入驻流程 -->
  <div class="entrprise_box">
    <div class="entrprise_title">
      <img src="@/assets/image/service/ico6.png" />
      <div class="title">企业入驻流程</div>
      <img src="@/assets/image/service/ico6.png" />
    </div>
    <div class="entrprise_mail">
      <div class="item">
        <div style="width:63px;margin:0 auto;">
          <PublicImage :src="require('@/assets/image/service/ico1.png')"></PublicImage>
        </div>
        <p class="title">注册并提交入驻申请</p>
        <p class="text">企业信息认证、提交入驻申请、创建用户</p>
      </div>
      <div class="icon"></div>
      <div class="item">
        <div style="width:57px;margin:0 auto;">
          <PublicImage :src="require('@/assets/image/service/ico2.png')"></PublicImage>
        </div>
        <p class="title">入驻审核</p>
        <p class="text">平台审核资质(1-3个工作日审核完成)</p>
      </div>
      <div class="icon"></div>
      <div class="item">
        <div style="width:63px;margin:0 auto;">
          <PublicImage :src="require('@/assets/image/service/ico3.png')"></PublicImage>
        </div>
        <p class="title">签约上线</p>
        <p class="text">审核通过、签约合同、录入产品上线</p>
      </div>
    </div>

    <div class="entrprise_list">
      <div class="left_list">
        <ContainerTitle text="已入驻商家" @jump="$router.push({path: '/serviceEnterFinish'})" :more="true"></ContainerTitle>
        <div class="list">
          <div
            class="item"
            v-for="(item, index) in agencyList"
            :key="index"
            @click="agencyDetail(item.id)"
          >
            <div class="msg">
              <div class="title">
                <div class="logo">
                  <PublicImage :src="item.avatar" v-if="item.avatar"></PublicImage>
                  <!-- <img :src="item.avatar" alt v-if="item.avatar" /> -->
                  <span v-else>{{item.short}}</span>
                </div>
                <span>{{item.agencyName}}</span>
              </div>
              <p class="text two_text">{{item.serviceDesc}}</p>
              <div class="tags" v-if="item.serviceTypeName.length">
                <p v-for="(item, index) in item.serviceTypeName" :key="index">{{item}}</p>
              </div>
            </div>
            <div class="scroe">
              <template v-if="item.grade">
                <p class="name">综合评分</p>
                <p class="number">
                  <span class="point">{{item.grade}}</span>
                  <span class="text">分</span>
                </p>
                <div class="star">
                  <Star :size="48" :score="item && item.grade"></Star>
                </div>
              </template>
               <p v-else class="name2">暂无评分</p>
            </div>
          </div>
        </div>
      </div>
      <div class="right_list">
        <ContainerTitle text="需求广场" @jump="$router.push({path: '/serviceDemandSquare'})" :more="true"></ContainerTitle>
        <!-- <div class="list">
          <div
            class="item"
            v-for="(item,index) in rementList"
            :key="index"
            @click="onGetInto(item)"
          >
            <p class="tips" v-if="item.appealTypeName!=null">{{item.appealTypeName}}</p>
            <p class="title two_text">{{item.title}}</p>
            <p class="des two_text">{{item.appealContent}}</p>
            <div class="end">
              <p class="time">{{item.createTime}}</p>
              <img src="@/assets/image/service/ico7.png" alt="">
              <span>{{item.viewNumbers}}</span>
            </div>
          </div>
        </div> -->
        <Rement :list="rementList"></Rement>
      </div>
    </div>
  </div>
</template>
<script>
import Star from './star'
import Rement from './rement'
import { getquerySettledAgency, getqserviceRequirement } from "@/common/api/service.js";
export default {
  props: {},
  components: {
    Star,
    Rement,
  },
  data() {
    return {
      agencyList: [],
      rementList: [],
    }
  },
  activated() {},
  created() {
    this.getquerySettledAgency()
    this.getqserviceRequirement()
  },
  methods: {
    // 跑转到商家详情页
    agencyDetail(agencyId) {
      console.log('id', agencyId)
      this.$router.push({
        path: 'serviceBusinessDetails',
        query: {
          agencyId,
        },
      })
    },
    // 已入驻的商家列表
    async getquerySettledAgency() {
      let obj = {
        current: 1,
        pageSize: 4,
      }
      let res = await getquerySettledAgency(obj)
      console.log('res11', res.result.data)
      // 把评分进行四舍五入保留一位小数
      res.result.data.forEach(item => {
        if(item.grade){
          return item.grade = Math.round(item.grade * 10) / 10
        }
      })
      if (res.status == 200 && res.result.data.length) {
        res.result.data.forEach((item) => {
          if (item.serviceTypeName) {
            item.serviceTypeName = item.serviceTypeName.split(',')
          }
          if (!item.avatar) {
            item.short = item.agencyName.substr(0, 1)
          }
        })
        this.agencyList = res.result.data
        console.log('this.agencyList', this.agencyList)
      }
    },
    //进入需求广场详情
    onGetInto(item) {
      if (item != '') {
        localStorage.setItem('DETAILS', JSON.stringify(item))
      }
      this.$router.push('demandDetails')
    },
    // 服务需求列表
    async getqserviceRequirement() {
      let obj = {
        pageNum: 1,
        pageSize: 3,
      }
      let res = await getqserviceRequirement(obj)
      console.log('res123', res)
      if (res.status == 200) {
        this.rementList = res.result.records
      }
    },
  },
}
</script>
<style lang="scss" scoped>
.entrprise_box {
  width: 1140px;
  min-height: 350px;
  margin: 40px auto 0;
  padding-bottom: 70px;
  .two_text {
    word-break: break-all;
    text-overflow: ellipsis;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .entrprise_title {
    font-size: 34px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 42px;
    .title {
      margin: 0 40px;
    }
    img {
      width: 55px;
      &:first-child {
        transform: rotate(180deg);
      }
    }
  }
  .entrprise_mail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 70px;
    .item {
      width: 371px;
      height: 232px;
      background: #f7fbff;
      border: 1px solid rgba(12, 94, 184, 0.4);
      border-radius: 4px;
      text-align: center;
      padding-top: 40px;
      box-sizing: border-box;
      flex-shrink: 0;
      cursor: pointer;
      img {
        height: 63px;
      }
      .title {
        font-size: 20px;
        font-weight: 700;
        margin: 20px 0 7px;
      }
      .text {
        font-size: 12px;
        color: #666666;
      }
    }
    .icon {
      width: 50px;
      height: 50px;
      background: #ffffff;
      border: 1px solid #d6d6d6;
      border-radius: 50%;
      background-image: url(../../../assets/image/service/ico8.png);
      background-repeat: no-repeat;
      background-size: 30px;
      background-position: center;
      margin: 0 -18px;
      position: relative;
      z-index: 1;
      flex-shrink: 0;
    }
  }
  .entrprise_list {
    display: flex;
    .list_title {
      display: flex;
      align-items: center;
      padding-bottom: 10px;
      border-bottom: 2px solid #045db9;
      color: #045db9;
      font-size: 20px;
      .more {
        font-size: 14px;
        margin-left: auto;
        color: #333;
      }
    }
    .left_list {
      width: 800px;
      .list {
        padding: 0 5px;
        text-align: left;
        .item {
          padding: 25px 10px 25px;
          border-bottom: 1px solid #eeeeee;
          display: flex;
          .msg {
            width: 390px;
            .title {
              display: flex;
              align-items: center;
              font-size: 22px;
              font-weight: bold;
              .logo {
                padding: 5px;
                flex-shrink: 0;
                border: 1px solid #045DB9;
                border-radius: 8px;
                margin-right: 10px;
                width: 50px;
                height: 50px;
                box-sizing: border-box;
                text-align: center;
                line-height: 40px;
                font-weight: 700;
                font-size: 30px;
                background: #045DB9;
                color: #fff;
                img {
                  width: 40px;
                  height: 40px;
                  object-fit: cover;
                  display: block;
                }
              }
            }
            .text {
              font-size: 14px;
              margin: 14px 0;
            }
            .tags {
              display: flex;
              flex-wrap: wrap;
              color: #f09450;
              font-size: 14px;
              margin: -8px -8px 0 0;
              p {
                padding: 4px 7px;
                background-color: #f7f1eb;
                border-radius: 3px;
                margin: 8px 8px 0 0;
              }
            }
          }
          .scroe {
            margin-left: 200px;
            flex-shrink: 0;
            align-self: flex-end;
            text-align: center;
            width: 170px;
            .name {
              font-size: 14px;
              font-weight: bold;
            }
            .name2{
              line-height: 125px;
              height: 125px;
            }
            .number {
              color: #db3f24;
              margin: 6px 0;
              padding-left: 27px;
              .point {
                font-size: 60px;
                font-weight: bold;
              }
              .text {
                font-size: 14px;
                margin-left: 5px;
              }
            }
            .star {
              display: flex;
              align-items: center;
              // img {
              //   width: 24px;
              //   height: 24px;
              //   margin-left: 8px;
              //   display: block;
              // }
            }
          }
        }
      }
    }
    .right_list {
      width: 300px;
      margin-left: auto;
    }
  }
}
</style>